package dome2;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 王圆豪
 * Date: 2024-05-23
 * Time: 18:08
 */
public class Test {
    public static void mySort(Student[] students) {
        for (int i = 0; i < students.length - 1; i++) {
            for (int j = 0; j < students.length - i -1; j++) {
                if (students[j].compareTo(students[j + 1]) > 0) {
                    Student tmp = students[j];
                    students[j] = students[j + 1];
                    students[j + 1] = tmp;
                }
            }
        }
    }

    public static void main(String[] args) {
//        Student student1 = new Student(5, "zhangsan");
//        Student student2 = new Student(10, "lisi");
//        Student student3 = new Student(7, "wangwu");

        Student[] students = new Student[3];
        students[0] = new Student(5, "zhangsan");
        students[1] = new Student(10, "lisi");
        students[2] = new Student(7, "wangwu");

//        System.out.println(student1.compareTo(student2));

        System.out.println("排序前：" + Arrays.toString(students));

//        Arrays.sort(students);
        mySort(students);

        System.out.println("排序后：" + Arrays.toString(students));

    }
}
